//
//  AUHomeCell.swift
//  rrrr
//
//  Created by A on 2025/9/22.
//

import UIKit
import SnapKit
import Kingfisher
class AUHomeCell: AUBaseCell {
    var roomModel:AURoomList?
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
    }
    required init?(coder: NSCoder) {
        fatalError("nnnn")

    }
    lazy var picView: UIImageView = {
        var pic = UIImageView()
        pic.contentMode = .scaleAspectFill
        pic.clipsToBounds = true
        return pic
    }()
    lazy var nameL: UILabel = {
        var label = UILabel()
        label.font = UIFont.systemFont(ofSize: 14)
        label.textColor = .black
        
        return label
    }()
    // MARK: - UI
    lazy var titleLabel: UILabel = {
        let label = UILabel()
        // 可根据需要自定义样式
        return label
    }()
    func configure(with model: AURoomList){
        self.roomModel = model
        picView.kf.setImage(with: URL(string: model.roomAvatarUrl ?? ""))
        nameL.text = model.roomName
        titleLabel.text = model.ownerNick
    }
    override func setupUI() {
        super.setupUI()
        contentView.addSubview(picView)
        picView.snp.makeConstraints { make in
            make.leading.equalTo(contentView.snp_leadingMargin).offset(0)
            make.top.equalTo(contentView.snp_topMargin).offset(0)
            make.trailing.equalTo(contentView.snp_trailingMargin).offset(0)
            make.height.equalTo(picView.snp.width)
        }
        contentView.addSubview(nameL)
        nameL.snp.makeConstraints { make in
            make.leading.equalTo(picView.snp_leadingMargin).offset(5)
            make.top.equalTo(picView.snp_bottomMargin).offset(15)
            
        }
        
        contentView.addSubview(titleLabel)
        titleLabel.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
    }
}
